home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
FromTheMag
/
JW FLV MEDIA PLAYER 4.2
/
mediaplayer.exe
/
player.swf
/
scripts
/
com
/
jeroenwijering
/
utils
/
Configger.as
< prev
next >
Wrap
Text File
|
2008-11-04
|
2KB
|
86 lines
package com.jeroenwijering.utils
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class Configger extends EventDispatcher
{
private var config:Object;
private var reference:Sprite;
private var loader:URLLoader;
public function Configger(param1:Sprite)
{
super();
reference = param1;
}
private function compareWrite(param1:Object) : void
{
var _loc2_:* = null;
for(_loc2_ in param1)
{
config[_loc2_.toLowerCase()] = Strings.serialize(param1[_loc2_.toLowerCase()]);
}
}
private function loadXML(param1:String) : void
{
var url:String = param1;
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE,xmlHandler);
try
{
loader.load(new URLRequest(url));
}
catch(err:Error)
{
throw err;
}
}
private function loadFlashvars() : void
{
compareWrite(reference.root.loaderInfo.parameters);
dispatchEvent(new Event(Event.COMPLETE));
}
public function load(param1:Object) : void
{
var _loc2_:String = null;
config = param1;
_loc2_ = reference.root.loaderInfo.parameters["config"];
if(_loc2_)
{
loadXML(Strings.decode(_loc2_));
}
else
{
loadFlashvars();
}
}
private function xmlHandler(param1:Event) : void
{
var _loc2_:XML = null;
var _loc3_:Object = null;
var _loc4_:XML = null;
_loc2_ = XML(param1.currentTarget.data);
_loc3_ = new Object();
for each(_loc4_ in _loc2_.children())
{
_loc3_[_loc4_.name()] = _loc4_.text();
}
compareWrite(_loc3_);
loadFlashvars();
}
}
}